import java.util.Arrays;
import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-15
 * Time: 15:21
 */
public class Demo04 {
    public static void main1(String[] args) {
        String s1 = "hel*lo";
        //小写转大写 （只会把小写字母变为大写字母，其他字符不变）
        s1 = s1.toUpperCase();
        System.out.println(s1);
        //大写转小写
        String s2 = "HEllo";
        s2 = s2.toLowerCase();
        System.out.println(s2);
    }

    public static void main2(String[] args) {
        String s1 = "hel*lo";
        //字符串转数组
        char[] ch = s1.toCharArray();
        System.out.println(Arrays.toString(ch));
        //数组转字符串
        String s2 = new String(ch);
        System.out.println(s2);
    }

    public static void main4(String[] args) {
        //以格式化的形式输出字符串
        String s1 = String.format("%d--%-d--%-d",2021,04,18);
        System.out.println(s1);
    }

    public static void main7(String[] args) {
        //s1.replace() 替换字符串中的指定字符
        String s1 = "abbbbccccddasdabd";
        s1 = s1.replace("ab","123");
        System.out.println(s1);
        //replaceFirst() 只替换第一个出现的
    }

    public static void main5(String[] args) {
        //s1.split() 分割字符串  用字符串数组接收
        String s1 = "abbbb ccccd dasd abd";
        String[]s2 = s1.split(" ");
        for (String s3 :s2) {
            System.out.println(s3);
        }
    }
    public static void main(String[] args) {
        //s1.subString() 字符串分割函数,从字符串中下标位置开始截取
        String s1 = "abbbb ccccd dasd abd";
        String s2 = s1.substring(5,7);
        System.out.println(s2);
    }
}
